/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.web.gwt.form.client.form.impl;

import com.genia.toolbox.web.gwt.form.client.form.InlineFormMultipleItem;
import com.genia.toolbox.web.gwt.form.client.visitor.FormVisitor;

/**
 * implementation of {@link InlineFormMultipleItem}.
 */
public class InlineFormMultipleItemImpl
    extends AbstractInlineFormItem
    implements InlineFormMultipleItem
{

  /**
   * whether the values must be sorted.
   */
  private boolean sortable = false;

  /**
   * whether the disposition of the sort buttons is vertical.
   */
  private boolean sortButtonsDispositionVertical = false;



  /**
   * make class visitable by visitor.
   * 
   * @param visitor
   *          the visitor implementation
   * @see com.genia.toolbox.web.gwt.form.client.form.Form#accept(com.genia.toolbox.web.gwt.form.client.visitor.FormVisitor)
   */
  public void accept(FormVisitor visitor)
  {
    visitor.visitInlineFormMultipleItem(this);
  }



  /**
   * Indicates whether some other object is "equal to" this one.
   * 
   * @param obj
   *          the reference object with which to compare.
   * @return <code>true</code> if this object is the same as the obj argument;
   *         <code>false</code> otherwise.
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(final Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!super.equals(obj)) {
      return false;
    }
    if (!(obj instanceof InlineFormMultipleItemImpl)) {
      return false;
    }
    InlineFormMultipleItemImpl other = (InlineFormMultipleItemImpl) obj;
    if (!isSortable() == other.isSortable()) {
      return false;
    }
    return (isSortButtonsDispositionVertical() == other.isSortButtonsDispositionVertical());
  }



  /**
   * returns the maximum number of sub forms to display. If the value is
   * <code>null</code>, there is not limit to the number of sub forms.
   * 
   * @return the maximum number of sub forms to display. If the value is
   *         <code>null</code>, there is not limit to the number of sub forms
   */
  public Integer getMaximumNumberOfSubForm()
  {
    return null;
  }



  /**
   * returns the minimum number of sub forms to display.
   * 
   * @return the minimum number of sub forms to display
   */
  public int getMinimumNumberOfSubForm()
  {
    return 0;
  }



  /**
   * getter for the sortable property.
   * 
   * @return the sortable
   */
  public boolean isSortable()
  {
    return sortable;
  }



  /**
   * getter for the sortButtonsDispositionVertical property.
   * 
   * @return the sortButtonsDispositionVertical
   */
  public boolean isSortButtonsDispositionVertical()
  {
    return sortButtonsDispositionVertical;
  }



  /**
   * setter for the sortable property.
   * 
   * @param sortable
   *          the sortable to set
   */
  public void setSortable(boolean sortable)
  {
    this.sortable = sortable;
  }



  /**
   * setter for the sortButtonsDispositionVertical property.
   * 
   * @param sortButtonsDispositionVertical
   *          the sortButtonsDispositionVertical to set
   */
  public void setSortButtonsDispositionVertical(boolean sortButtonsDispositionVertical)
  {
    this.sortButtonsDispositionVertical = sortButtonsDispositionVertical;
  }
}
